package api

import (
	"api-gatew/basic/config"
	__ "api-gatew/basic/proto"
	"api-gatew/handler/request"
	"github.com/gin-gonic/gin"
)

func Longin(c *gin.Context) {
	var r request.Longin
	if err := c.ShouldBind(&r); err != nil {
		c.JSON(400, gin.H{
			"code": 400,
			"msg":  "异常",
			"data": err.Error(),
		})
		return
	}
	longin, err := config.EwClient.GetUserInfo(config.Ctx, &__.GetUserInfoReq{
		Mobile:   r.Mobile,
		Password: r.Password,
	})
	if err != nil {
		c.JSON(400, gin.H{
			"code": 400,
			"msg":  "异常了",
			"data": false,
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "登录成功",
		"data": longin.Id,
	})
	return
}
